<template>
  <div>
    <div class="student-home-header">
      <ul class="stu-menu-icon">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
      </ul>
      <div class="stu-name">小明</div>
      <div class="stu-avatar">
        <img src="~images/common/student_avatar.png" />
      </div>
      <div class="stu-statis-title">
        <span>请假 (次)</span>
        <span>异常 (次)</span>
      </div>
      <div class="stu-statis-content">
        <span><img src="~images/default/home_leave_icon.png" alt=""></span>
        <span>{{leaveNum}}</span>
        <span><img src="~images/default/clock.png" alt=""></span>
        <span>{{abnormalNum}}</span>
      </div>
      <div class="leave-btn" @click="$router.push('/stuLeave')">我要请假</div>
    </div>
    <!-- 日历 -->
    <Calendar />
    <!-- 异常 -->
    <div v-show="abnormalData.length > 0">
      <div v-for="(item, index) in abnormalData" :key="index">
        <StuAbnormalM
          :dataInfo="item"
        />
      </div>
    </div>
    <!-- 请假 标题 -->
    <StuLeaveM />
    <!-- 申请 -->
    <StuAppliCard
      :tableData="leaveData"
    />
    <div style="height:30px"></div>
  </div>
</template>

<script>
import StuAppliCard from 'comps/StuAppliCard.vue'
export default {
  data() {
    return {
      leaveNum: 0,
      abnormalNum: 0,
      leaveData: [],
      abnormalData: [],
    }
  },
  components: {
    StuAppliCard,
  },
  created() {
    this.getIndexData()
  },
  methods: {
    getIndexData() {
      /* 首页 请假 异常统计 */
      this.$api.student.getIndexData({}).then(res=> {
        this.leaveNum = res.data.leaveCount
        this.abnormalNum = res.data.abnormalCount
        const data = {
          'leave':[
            {
              'id':2,
              'start_time':'2020-12-16 10:17:42',
              'end_time':'2020-12-21 12:10:00',
              'desc':'请假原因1',
              'status':1,
              'address':'请假地点',
              'reject_desc':null,
              'admin_realname':null,
              'admin_tel':null,
            },
          ],
          'abnormalData': [
            {
              'state':3,
              'time':1608085062,
              'temperature':null,
              'status_title':'晚归',
            },
            {
              'state':5,
              'time':1608085062,
              'temperature':38,
              'status_title':'体温异常',
            },
          ],
          'leaveCount':2,
          'abnormalCount':1,
        }
        this.leaveData= data.leave
        this.abnormalData = data.abnormalData
      })
    },
    leaveClick() {
      this.$router.push({
        path:'/stuLeave',
        query: {
          stuId: '2',
        },
      })
    },
  },
}
</script>
<style lang='scss' scoped>
.student-home-header {
  position: relative;
  width: 100%;
  height: 170px;
  background: url('~images/theme/header_bg.png') no-repeat;
  background-size: 100% 100%;
  .stu-menu-icon {
    &>li {
      position: absolute;
      width: 6px;
      height: 6px;
      border-radius: 3px;
      background: #FFFFFF;
      &:first-child {
        top: 33px;
        left: 20px;
      }
      &:nth-child(2) {
        top: 33px;
        left: 32px;
      }
      &:nth-child(3) {
        top: 45px;
        left: 20px;
      }
      &:nth-child(4) {
        top: 45px;
        left: 32px;
      }
    }
  }
  .stu-name {
    position: absolute;
    top: 33px;
    right: 58px;
    font-size: 14px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #FFFFFF;
  }
  .stu-avatar {
    position: absolute;
    top: 27px;
    right: 20px;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px dashed #8C97B2;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .stu-statis-title {
    position: absolute;
    left: 20px;
    bottom: 77px;
    span {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #A6B5D4;
      &:last-child {
        margin-left: 32px;
      }
    }
  }
  .stu-statis-content {
    &>span {
      position: absolute;
      &:first-child {
        left: 20px;
        bottom: 32px;
        display: grid;
        place-items: center;
        width: 17px;
        height: 17px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      &:nth-child(2) {
        left: 49px;
        bottom: 19px;
        font-size: 48px;
        font-family: JCHEadA;
        color: #FFFFFF;
      }
      &:nth-child(3) {
        display: grid;
        place-items: center;
        width: 17px;
        height: 17px;
        left:110px;
        bottom: 32px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      &:last-child {
        left: 139px;
        bottom: 19px;
        font-size: 48px;
        font-family: JCHEadA;
        color: #FFFFFF;
      }
    }
  }
  .leave-btn {
    position: absolute;
    bottom: 30px;
    right: 20px;
    display: grid;
    place-items: center;
    width: 99px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-size: 14px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFFFFF;
  }
}
</style>